home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kit PC World De Ampliacion De Windows 95
/
Kit PC World de ampliacion de Windows 95.iso
/
internet
/
sweeper
/
samples
/
olecon~1
/
framewrk
/
ctlembed.cpp
< prev
next >
Wrap
Text File
|
1995-11-30
|
57KB
|
1,967 lines
//=--------------------------------------------------------------------------=
// ControlEmbedding.Cpp
//=--------------------------------------------------------------------------=
// Copyright 1995 Microsoft Corporation. All Rights Reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//=--------------------------------------------------------------------------=
//
// implementation of the interfaces required for inplace activation for
// COleControl
//
#include "IPServer.H"
#include "CtrlObj.H"
#include "CtlHelp.H"
#include "Globals.H"
#include "StdEnum.H"
#include "Util.H"
// for ASSERT and FAIL
//
SZTHISFILE
//=--------------------------------------------------------------------------=
// all controls support the following in-place verbs at an absolute minimum.
//
#define CINPLACEVERBS 4
const VERBINFO rgInPlaceVerbs [] = {
{ OLEIVERB_SHOW, 0, 0, 0},
{ OLEIVERB_HIDE, 0, 0, 0},
{ OLEIVERB_INPLACEACTIVATE, 0, 0, 0},
{ OLEIVERB_PRIMARY, 0, 0, 0}
};
// NOTE: Resource ID for Properties string must be 1000
//
const VERBINFO ovProperties =
{ CTLIVERB_PROPERTIES, 1000, 0, OLEVERBATTRIB_ONCONTAINERMENU };
const VERBINFO ovUIActivate =
{ OLEIVERB_UIACTIVATE, 0, 0, 0};
//=--------------------------------------------------------------------------=
// COleControl::GetControlInfo (IOleControl)
//=--------------------------------------------------------------------------=
// returns some information on a control, such as an accelerator table, and
// flags. really used for keyboard handling and mnemonics
//
// Parameters:
// CONTROLINFO * - [in] where to put said information
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::GetControlInfo
(
CONTROLINFO *pControlInfo
)
{
CHECK_POINTER(pControlInfo);
// certain hosts have a bug in which it doesn't initialize the cb in the
// CONTROLINFO structure, so we can only assert on that here.
// maggots!
//
ASSERT(pControlInfo->cb == sizeof(CONTROLINFO), "Host doesn't initialize CONTROLINFO structure");
pControlInfo->hAccel = m_hAccel;
pControlInfo->cAccel = m_cAccel;
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::OnMnemonic [IOleControl]
//=--------------------------------------------------------------------------=
// the container has decided to pass on a key that the end-user has pressed to
// us. default implementation will be to just activate the control. people
// looking for more functionality should override this method.
//
// Parameters:
// LPMSG - [in] message for this mnemonic
//
// Output:
// HRESULT - S_OK, E_POINTER
//
// Notes:
//
STDMETHODIMP COleControl::OnMnemonic
(
LPMSG pMsg
)
{
// default implementation is to just activate our control. user can override
// if they want more interesting behaviour.
//
return InPlaceActivate(OLEIVERB_UIACTIVATE);
}
//=--------------------------------------------------------------------------=
// COleControl:OnAmbientPropertyChange [IOleControl]
//=--------------------------------------------------------------------------=
// a container calls this whenever it changes an ambient property.
//
// Parameters:
// DISPID - [in] dispid of the property that changed.
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::OnAmbientPropertyChange
(
DISPID dispid
)
{
// if we're being told about a change in mode [design/run] then
// remember that so our stashing of mode will update itself
// correctly
//
if (dispid == DISPID_AMBIENT_USERMODE || dispid == DISPID_UNKNOWN)
m_fModeFlagValid = FALSE;
// just pass this on to the derived control and see if they want
// to do anything with it.
//
AmbientPropertyChanged(dispid);
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControL::FreezeEvents [IOleControl]
//=--------------------------------------------------------------------------=
// allows a container to freeze all of a controls events. when events are
// frozen, a control will not fire any of them.
//
// Parameters:
// BOOL - [in] TRUE means FREEZE, FALSE means THAW
//
// Output:
// HRESULT - S_OK
//
// Notes:
// - we maintain an internal count of freezes versus thaws.
//
STDMETHODIMP COleControl::FreezeEvents
(
BOOL fFreeze
)
{
// by default, we don't care. user can override if they want to.
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::SetClientSite [IOleObject]
//=--------------------------------------------------------------------------=
// informs the embedded object [control] of it's client site [display
// location] within it's container
//
// Parameters:
// IOleClientSite * - [in] pointer to client site.
//
// Output:
// HRESULT - S_OK, E_UNEXPECTED
//
// Notes:
//
STDMETHODIMP COleControl::SetClientSite
(
IOleClientSite *pClientSite
)
{
RELEASE_OBJECT(m_pClientSite);
RELEASE_OBJECT(m_pControlSite);
RELEASE_OBJECT(m_pSimpleFrameSite);
// store away the new client site
//
m_pClientSite = pClientSite;
// if we've actually got one, then get some other interfaces we want to keep
// around, and keep a handle on it
//
if (m_pClientSite) {
m_pClientSite->AddRef();
m_pClientSite->QueryInterface(IID_IOleControlSite, (void **)&m_pControlSite);
if (OLEMISCFLAGSOFCONTROL(m_ObjectType) & OLEMISC_SIMPLEFRAME)
m_pClientSite->QueryInterface(IID_ISimpleFrameSite, (void **)&m_pSimpleFrameSite);
}
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::GetClientSite [IOleObject]
//=--------------------------------------------------------------------------=
// obtains a pointer to the controls client site.
//
// Parameters:
// IOleClientSite ** - [out]
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::GetClientSite
(
IOleClientSite **ppClientSite
)
{
CHECK_POINTER(ppClientSite);
*ppClientSite = m_pClientSite;
ADDREF_OBJECT(*ppClientSite);
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::SetHostNames [IOleObject]
//=--------------------------------------------------------------------------=
// Provides the control with the name of its container application and the
// compound document in which it is embedded
//
// Parameters:
// LPCOLESTR - [in] name of container application
// LPCOLESTR - [in] name of container document
//
// Output:
// HRESULT - S_OK
//
// Notes:
// - we don't care about this
//
STDMETHODIMP COleControl::SetHostNames
(
LPCOLESTR szContainerApp,
LPCOLESTR szContainerObject
)
{
// we don't care about these
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::Close [IOleObject]
//=--------------------------------------------------------------------------=
// Changes the control from the running to the loaded state
//
// Parameters:
// DWORD - [in] indicates whether to save the object before closing
//
// Output:
// HRESULT - S_OK, OLE_E_PROMPTSAVECANCELLED
//
// Notes:
//
STDMETHODIMP COleControl::Close
(
DWORD dwSaveOption
)
{
HRESULT hr;
if (m_fInPlaceActive) {
hr = InPlaceDeactivate();
RETURN_ON_FAILURE(hr);
}
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::SetMoniker [IOleObject]
//=--------------------------------------------------------------------------=
// Notifies an object of its container's moniker, the object's own moniker
// relative to the container, or the object's full moniker
//
// Parameters:
// DWORD - [in] which moniker is being set
// IMoniker * - [in] the moniker
//
// Output:
// HRESULT - S_OK, E_FAIL
//
// Notes:
// - we don't support monikers.
//
STDMETHODIMP COleControl::SetMoniker
(
DWORD dwWhichMoniker,
IMoniker *pMoniker
)
{
// homey don't play that.
//
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::GetMoniker [IOleObject]
//=--------------------------------------------------------------------------=
// Returns a embedded object's moniker, which the caller can use to link to
// the object
//
// Parameters:
// DWORD - [in] how it's assigned
// DWORD - [in] which moniker
// IMoniker ** - [out] duh.
//
// Output:
// HRESULT - E_NOTIMPL
//
// Notes:
// - we don't support monikers
//
STDMETHODIMP COleControl::GetMoniker
(
DWORD dwAssign,
DWORD dwWhichMoniker,
IMoniker **ppMonikerOut
)
{
// homey don't play that
//
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::InitFromData [IOleObject]
//=--------------------------------------------------------------------------=
// Initializes a newly created object with data from a specified data object,
// which can reside either in the same container or on the Clipboard
//
// Parameters:
// IDataObject* - [in] data object with the data
// BOOL - [in] how object is created
// DWORD - reserved
//
// Output:
// HRESULT - S_OK, S_FALSE, E_NOTIMPL, OLE_E_NOTRUNNING
//
// Notes:
// - we don't have data object support
//
STDMETHODIMP COleControl::InitFromData
(
IDataObject *pDataObject,
BOOL fCreation,
DWORD dwReserved
)
{
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::GetClipboardData [IOleObject]
//=--------------------------------------------------------------------------=
// Retrieves a data object containing the current contents of the control.
// Using the pointer to this data object, it is possible to create a new control
// with the same data as the original
//
// Parameters:
// DWORD - reserved
// IDataObject ** - [out] data object for this control
//
// Output:
// HREUSLT - S_OK, E_NOTIMPL, OLE_E_NOTRUNNING
//
// Notes:
//
STDMETHODIMP COleControl::GetClipboardData
(
DWORD dwReserved,
IDataObject **ppDataObject
)
{
*ppDataObject = NULL; // be a good neighbour
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::DoVerb [IOleObject]
//=--------------------------------------------------------------------------=
// Requests an object to perform an action in response to an end-user's
// action.
//
// Parameters:
// LONG - [in] verb to be performed
// LPMSG - [in] event that invoked the verb
// IOleClientSite * - [in] the controls active client site
// LONG - [in] reserved
// HWND - [in] handle of window containing the object.
// LPCRECT - [in] pointer to objects's display rectangle
//
// Output:
// HRESULT - S_OK, OLE_E_NOTINPLACEACTIVE, OLE_E_CANT_BINDTOSOURCE,
// DV_E_LINK, OLEOBJ_S_CANNOT_DOVERB_NOW, OLEOBJ_S_INVALIDHWND,
// OLEOBJ_E_NOVERBS, OLEOBJ_S_INVALIDVERB, MK_E_CONNECT,
// OLE_CLASSDIFF, E_NOTIMPL
//
// Notes:
//
STDMETHODIMP COleControl::DoVerb
(
LONG lVerb,
LPMSG pMsg,
IOleClientSite *pActiveSite,
LONG lIndex,
HWND hwndParent,
LPCRECT prcPosRect
)
{
HRESULT hr;
switch (lVerb) {
case OLEIVERB_SHOW:
case OLEIVERB_INPLACEACTIVATE:
case OLEIVERB_UIACTIVATE:
return InPlaceActivate(lVerb);
case OLEIVERB_HIDE:
UIDeactivate();
if (m_fInPlaceVisible) SetInPlaceVisible(FALSE);
return S_OK;
// we used to have OLEIVERB_PRIMARY InPlaceActivate Ourselves, but it
// turns out that the CDK and certain hosts expect this to show the
// properties instead. Users can change what this verb does at will.
//
case OLEIVERB_PRIMARY:
case CTLIVERB_PROPERTIES:
case OLEIVERB_PROPERTIES:
{
// show the frame ourselves if the hose can't.
//
if (m_pControlSite) {
hr = m_pControlSite->ShowPropertyFrame();
if (hr != E_NOTIMPL)
return hr;
}
IUnknown *pUnk = (IUnknown *)(IOleObject *)this;
MAKE_WIDEPTR_FROMANSI(pwsz, NAMEOFOBJECT(m_ObjectType));
ModalDialog(TRUE);
hr = OleCreatePropertyFrame(GetActiveWindow(),
GetSystemMetrics(SM_CXSCREEN) / 2,
GetSystemMetrics(SM_CYSCREEN) / 2,
pwsz,
1,
&pUnk,
CPROPPAGESOFCONTROL(m_ObjectType),
(LPCLSID)*(PPROPPAGESOFCONTROL(m_ObjectType)),
g_lcidLocale,
NULL, NULL);
ModalDialog(FALSE);
return hr;
}
default:
// if it's a derived-control defined verb, pass it on to them
//
if (lVerb > 0) {
hr = DoCustomVerb(lVerb);
if (hr == OLEOBJ_S_INVALIDVERB) {
// unrecognised verb -- just do the primary verb and
// activate the sucker.
//
hr = InPlaceActivate(OLEIVERB_PRIMARY);
return (FAILED(hr)) ? hr : OLEOBJ_S_INVALIDVERB;
} else
return hr;
} else {
FAIL("Unrecognized Negative verb in DoVerb(). bad.");
return E_NOTIMPL;
}
break;
}
// dead code
FAIL("Gaaaaaak! this should be dead code!");
}
//=--------------------------------------------------------------------------=
// COleControl::EnumVerbs [IOleObject]
//=--------------------------------------------------------------------------=
// create an enumerator object for the verbs this object supports.
//
// Parameters:
// IEnumOleVERB ** - [out] new enumerator.
//
// Output:
// HRESULT - S_OK, E_OUTOFMEMORY
//
// Notes:
//
STDMETHODIMP COleControl::EnumVerbs
(
IEnumOLEVERB **ppEnumVerbs
)
{
int cVerbs;
OLEVERB *rgVerbs, *pVerb;
DWORD dw = OLEMISCFLAGSOFCONTROL(m_ObjectType);
BOOL fCanInPlace = !(dw & OLEMISC_INVISIBLEATRUNTIME) || (dw & OLEMISC_ACTIVATEWHENVISIBLE);
BOOL fCanUIActivate = !(dw & OLEMISC_NOUIACTIVATE);
BOOL fHasProperties = (CPROPPAGESOFCONTROL(m_ObjectType) != 0);
int cVerbExtra = CCUSTOMVERBSOFCONTROL(m_ObjectType);
// count up all the verbs
//
cVerbs = (fCanInPlace ? CINPLACEVERBS : 0) + (fCanUIActivate ? 1 : 0)
+ (fHasProperties ? 1 : 0) + cVerbExtra;
// if there aren't any, this suddenly gets really easy !
//
if (cVerbs == 0)
return OLEOBJ_E_NOVERBS;
// HeapAlloc some storage for these dudes so that we can pass them on to
// the standard enumerator!
//
if (! (rgVerbs = (OLEVERB *)HeapAlloc(g_hHeap, 0, cVerbs * sizeof(OLEVERB))))
return E_OUTOFMEMORY;
// start copying over verbs. first, the in-place guys
//
pVerb = rgVerbs;
if (fCanInPlace) {
memcpy(pVerb, rgInPlaceVerbs, CINPLACEVERBS * sizeof(OLEVERB));
pVerb += CINPLACEVERBS;
}
if (fCanUIActivate)
memcpy(pVerb++, &ovUIActivate, sizeof(OLEVERB));
// if their control has properties, copy that over now.
//
if (fHasProperties) {
memcpy(pVerb, &ovProperties, sizeof(OLEVERB));
pVerb++;
}
// finally, any custom verbs!
//
if (cVerbExtra) {
memcpy(pVerb, CUSTOMVERBSOFCONTROL(m_ObjectType), sizeof(OLEVERB) * cVerbExtra);
}
*ppEnumVerbs = (IEnumOLEVERB *) (IEnumGeneric *) new CStandardEnum(IID_IEnumOLEVERB,
cVerbs, sizeof(OLEVERB), rgVerbs, CopyOleVerb);
if (!*ppEnumVerbs)
return E_OUTOFMEMORY;
// this forces us to go and look for the Localized DLLs. This is necessary here
// because the CopyOleVerb will get information from localized resources, but
// will only use the global GetResourceHandle, which only uses the global value
// for the LCID. This turns out to not be a big performance hit, since this
// function is typically only called in design mode, and we stash this value.
//
GetResourceHandle();
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::Update [IOleObject]
//=--------------------------------------------------------------------------=
// Updates an object handler's or link object's data or view caches.
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::Update
(
void
)
{
// nothing to do!!!
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::IsUpToDate [IOleObject]
//=--------------------------------------------------------------------------=
// Checks recursively whether or not an object is up to date.
//
// Output:
// HRESULT - S_OK, S_FALSE, OLE_E_UNVAILABLE
//
// Notes:
//
STDMETHODIMP COleControl::IsUpToDate
(
void
)
{
// we're always up to date
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::GetUserClassID [IOleObject]
//=--------------------------------------------------------------------------=
// Returns the controls class identifier, the CLSID corresponding to the
// string identifying the object to an end user.
//
// Parameters:
// CLSID * - [in] where to put the CLSID
//
// Output:
// HRESULT - S_OK, E_FAIL
//
// Notes:
//
STDMETHODIMP COleControl::GetUserClassID
(
CLSID *pclsid
)
{
// this is the same as IPersist::GetClassID
//
return GetClassID(pclsid);
}
//=--------------------------------------------------------------------------=
// COleControl::GetUserType [IOleObject]
//=--------------------------------------------------------------------------=
// Retrieves the user-type name of the control for display in user-interface
// elements such as menus, list boxes, and dialog boxes.
//
// Parameters:
// DWORD - [in] specifies the form of the type name.
// LPOLESTR * - [out] where to put user type
//
// Output:
// HRESULT - S_OK, OLE_S_USEREG, E_OUTOFMEMORY
//
// Notes:
//
STDMETHODIMP COleControl::GetUserType
(
DWORD dwFormOfType,
LPOLESTR *ppszUserType
)
{
*ppszUserType = OLESTRFROMANSI(NAMEOFOBJECT(m_ObjectType));
return (*ppszUserType) ? S_OK : E_OUTOFMEMORY;
}
//=--------------------------------------------------------------------------=
// COleControl::SetExtent [IOleObject]
//=--------------------------------------------------------------------------=
// Informs the control of how much display space its container has assigned it.
//
// Parameters:
// DWORD - [in] which form or 'aspect' is to be displayed.
// SIZEL * - [in] size limit for the control.
//
// Output:
// HRESULT - S_OK, E_FAIL, OLE_E_NOTRUNNING
//
// Notes:
//
STDMETHODIMP COleControl::SetExtent
(
DWORD dwDrawAspect,
SIZEL *psizel
)
{
BOOL f;
if (dwDrawAspect & DVASPECT_CONTENT) {
// change the units to pixels, and resize the control.
//
HiMetricToPixel(psizel, &m_Size);
// first call the user version. if they return FALSE, they want
// to keep their current size
//
f = OnSetExtent(psizel);
if (!f) PixelToHiMetric(&m_Size, psizel);
if (m_fInPlaceActive) {
RECT rect;
GetWindowRect(m_hwnd, &rect);
MapWindowPoints(NULL, m_hwndParent, (LPPOINT)&rect, 2);
rect.right = rect.left + m_Size.cx;
rect.bottom = rect.top + m_Size.cy;
m_pInPlaceSite->OnPosRectChange(&rect);
if (m_hwnd) {
// just go and resize
//
if (m_hwndReflect)
SetWindowPos(m_hwndReflect, 0, 0, 0, m_Size.cx, m_Size.cy,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
SetWindowPos(m_hwnd, 0, 0, 0, m_Size.cx, m_Size.cy,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
} else if (m_hwnd) {
SetWindowPos(m_hwnd, NULL, 0, 0, m_Size.cx, m_Size.cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
} else {
ViewChanged();
}
// return code depending on whether or not user accepted given
// size
//
return (f) ? S_OK : E_FAIL;
} else {
// we don't support any other aspects.
//
return DV_E_DVASPECT;
}
// dead code
FAIL("Gaaaaak! Dead Code!");
}
//=--------------------------------------------------------------------------=
// COleControl::GetExtent [IOleObject]
//=--------------------------------------------------------------------------=
// Retrieves the control's current display size.
//
// Parameters:
// DWORD - [in] aspect
// SIZEL * - [in] where to put results
//
// Output:
// S_OK, E_INVALIDARG
//
// Notes:
//
STDMETHODIMP COleControl::GetExtent
(
DWORD dwDrawAspect,
SIZEL *pSizeLOut
)
{
if (dwDrawAspect & DVASPECT_CONTENT) {
PixelToHiMetric((const SIZEL *)&m_Size, pSizeLOut);
return S_OK;
} else {
return DV_E_DVASPECT;
}
// dead code
}
//=--------------------------------------------------------------------------=
// COleControl::Advise [IOleObject]
//=--------------------------------------------------------------------------=
// establishes and advisory connection between the control and the container,
// in which the control will notify the container of certain events.
//
// Parameters:
// IAdviseSink * - [in] advise sink of calling object
// DWORD - [out] cookie
//
// Output:
// HRESULT - S_OK, E_OUTOFMEMORY
//
// Notes:
//
STDMETHODIMP COleControl::Advise
(
IAdviseSink *pAdviseSink,
DWORD *pdwConnection
)
{
HRESULT hr;
// if we haven't yet created a standard advise holder object, do so
// now
//
if (!m_pOleAdviseHolder) {
hr = CreateOleAdviseHolder(&m_pOleAdviseHolder);
RETURN_ON_FAILURE(hr);
}
// just get it to do the work for us!
//
return m_pOleAdviseHolder->Advise(pAdviseSink, pdwConnection);
}
//=--------------------------------------------------------------------------=
// COleControl::Unadvise [IOleObject]
//=--------------------------------------------------------------------------=
// Deletes a previously established advisory connection.
//
// Parameters:
// DWORD - [in] connection cookie
//
// Output:
// HRESULT - S_OK, E_FAIL, OLE_E_NOCONNECTION
//
// Notes:
//
STDMETHODIMP COleControl::Unadvise
(
DWORD dwConnection
)
{
if (!m_pOleAdviseHolder) {
FAIL("Somebody called Unadvise on IOleObject without calling Advise!");
CONNECT_E_NOCONNECTION;
}
return m_pOleAdviseHolder->Unadvise(dwConnection);
}
//=--------------------------------------------------------------------------=
// COleControl::EnumAdvise [IOleObject]
//=--------------------------------------------------------------------------=
// Enumerates the advisory connections registered for an object, so a container
// can know what to release prior to closing down.
//
// Parameters:
// IEnumSTATDATA ** - [out] where to put enumerator
//
// Output:
// HRESULT - S_OK, E_FAIL, E_NOTIMPL
//
// Notes:
//
STDMETHODIMP COleControl::EnumAdvise
(
IEnumSTATDATA **ppEnumOut
)
{
if (!m_pOleAdviseHolder) {
FAIL("Somebody Called EnumAdvise without setting up any connections");
*ppEnumOut = NULL;
return E_FAIL;
}
return m_pOleAdviseHolder->EnumAdvise(ppEnumOut);
}
//=--------------------------------------------------------------------------=
// COleControl::GetMiscStatus [IOleObject]
//=--------------------------------------------------------------------------=
// Returns a value indicating the status of an object at creation and loading.
//
// Parameters:
// DWORD - [in] aspect desired
// DWORD * - [out] where to put the bits.
//
// Output:
// HRESULT - S_OK, OLE_S_USEREG, CO_E_CLASSNOTREG, CO_E_READREGDB
//
// Notes:
//
STDMETHODIMP COleControl::GetMiscStatus
(
DWORD dwAspect,
DWORD *pdwStatus
)
{
CHECK_POINTER(pdwStatus);
if (dwAspect == DVASPECT_CONTENT) {
*pdwStatus = OLEMISCFLAGSOFCONTROL(m_ObjectType);
return S_OK;
} else {
return DV_E_DVASPECT;
}
// dead code
}
//=--------------------------------------------------------------------------=
// COleControl::SetColorScheme [IOleObject]
//=--------------------------------------------------------------------------=
// Specifies the color palette that the object application should use when it
// edits the specified object.
//
// Parameters:
// LOGPALETTE * - [in] new palette
//
// Output:
// HRESULT - S_OK, E_NOTIMPL, OLE_E_PALETTE, OLE_E_NOTRUNNING
//
// Notes:
// - we don't care.
//
STDMETHODIMP COleControl::SetColorScheme
(
LOGPALETTE *pLogpal
)
{
// homey don't play that. ignore
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::GetWindow [IOleWindow/IOleInPlaceObject]
//=--------------------------------------------------------------------------=
// Returns the window handle to one of the windows participating in in-place
// activation (frame, document, parent, or in-place object window).
//
// Parameters:
// HWND * - [out] where to return window handle.
//
// Output:
// HRESULT - S_OK, E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, E_FAIL
//
// Notes:
//
STDMETHODIMP COleControl::GetWindow
(
HWND *phwnd
)
{
*phwnd = GetOuterWindow();
return (*phwnd) ? S_OK : E_UNEXPECTED;
}
//=--------------------------------------------------------------------------=
// COleControl::ContextSensitiveHelp [IOleWindow/IOleInPlaceObject]
//=--------------------------------------------------------------------------=
// Determines whether context-sensitive help mode should be entered during an
// in-place activation session.
//
// Parameters:
// BOOL - [in] whether or not to enter help mode.
//
// Output:
// HRESULT - S_OK, E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED
//
// Notes:
//
STDMETHODIMP COleControl::ContextSensitiveHelp
(
BOOL fEnterMode
)
{
// homey don't play that.
//
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::InPlaceActivate
//=--------------------------------------------------------------------------=
// activates the control, and depending on the verb, optionally ui activates
// it as well.
//
// Parameters:
// LONG - [in] the verb that caused us to activate
//
// Output:
// HRESULT
//
// Notes:
//
HRESULT COleControl::InPlaceActivate
(
LONG lVerb
)
{
HRESULT hr;
// if we don't have a client site, then there's not much to do.
//
if (!m_pClientSite)
return S_OK;
// get an InPlaceSite pointer
//
if (!m_pInPlaceSite) {
hr = m_pClientSite->QueryInterface(IID_IOleInPlaceSite, (void **)&m_pInPlaceSite);
RETURN_ON_FAILURE(hr);
}
// if we're not already active, go and do it.
//
if (!m_fInPlaceActive) {
OLEINPLACEFRAMEINFO InPlaceFrameInfo;
RECT rcPos, rcClip;
// ask for permission and notify the container we're going active.
//
hr = m_pInPlaceSite->CanInPlaceActivate();
if (hr != S_OK) return (FAILED(hr)) ? E_FAIL : hr;
hr = m_pInPlaceSite->OnInPlaceActivate();
RETURN_ON_FAILURE(hr);
m_fInPlaceActive = TRUE;
InPlaceFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
// get our parent window
//
hr = m_pInPlaceSite->GetWindow(&m_hwndParent);
if (!FAILED(hr))
// get our display and clipping rectangles
//
hr = m_pInPlaceSite->GetWindowContext(&m_pInPlaceFrame, &m_pInPlaceUIWindow,
&rcPos, &rcClip, &InPlaceFrameInfo);
if (FAILED(hr)) {
InPlaceDeactivate();
return hr;
}
// make sure we'll display ourselves in the correct location with the correct size
//
SetInPlaceParent(m_hwndParent);
SetObjectRects(&rcPos, &rcClip);
// create the window, and display it.
//
CreateInPlaceWindow(rcPos.left, rcPos.top);
}
// if we're not inplace visible yet, do so now.
//
if (!m_fInPlaceVisible)
SetInPlaceVisible(TRUE);
// if we weren't asked to UIActivate, then we're done.
//
if (lVerb != OLEIVERB_PRIMARY && lVerb != OLEIVERB_UIACTIVATE)
return S_OK;
// if we're not already UI active, do sow now.
//
if (!m_fUIActive) {
m_fUIActive = TRUE;
// inform the container of our intent
//
m_pInPlaceSite->OnUIActivate();
// take the focus [which is what UI Activation is all about !]
//
SetFocus(m_hwnd);
// set up the active object [us] with the container.
//
m_pInPlaceFrame->SetActiveObject((IOleInPlaceActiveObject *)this, NULL);
if (m_pInPlaceUIWindow)
m_pInPlaceUIWindow->SetActiveObject((IOleInPlaceActiveObject *)this, NULL);
// we have to explicitly say we don't wany any border space.
//
m_pInPlaceFrame->SetBorderSpace(NULL);
if (m_pInPlaceUIWindow)
m_pInPlaceUIWindow->SetBorderSpace(NULL);
}
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::InPlaceDeactivate [IOleInPlaceObject]
//=--------------------------------------------------------------------------=
// Deactivates an active in-place object and discards the object's undo state.
//
// Output:
// HRESULT - S_OK, E_UNEXPECTED
//
// Notes:
//
STDMETHODIMP COleControl::InPlaceDeactivate
(
void
)
{
// if we're not in-place active yet, then this is easy.
//
if (!m_fInPlaceActive)
return S_OK;
// transition from UIActive back to active
//
if (m_fUIActive)
UIDeactivate();
m_fInPlaceActive = FALSE;
m_fInPlaceVisible = FALSE;
// tell our window to go play with somebody else temporarily.
//
if (m_hwnd) {
// so our window proc doesn't crash.
//
BeforeDestroyWindow();
SetWindowLong(m_hwnd, GWL_USERDATA, 0xFFFFFFFF);
DestroyWindow(m_hwnd);
m_hwnd = NULL;
if (m_hwndReflect) {
SetWindowLong(m_hwndReflect, GWL_USERDATA, 0);
DestroyWindow(m_hwndReflect);
m_hwndReflect = NULL;
}
}
RELEASE_OBJECT(m_pInPlaceFrame);
RELEASE_OBJECT(m_pInPlaceUIWindow);
m_pInPlaceSite->OnInPlaceDeactivate();
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::UIDeactivate [IOleInPlaceObject]
//=--------------------------------------------------------------------------=
// transitions us from UI Active to merely being active [visible] for
// a control, this doesn't mean all that much.
//
// Output:
// HRESULT - S_OK, E_UNEXPECTED
//
// Notes:
//
STDMETHODIMP COleControl::UIDeactivate
(
void
)
{
// if we're not UIActive, not much to do.
//
if (!m_fUIActive)
return S_OK;
m_fUIActive = FALSE;
// notify everybody that we're no longer UIActive
//
if (m_pInPlaceUIWindow) m_pInPlaceUIWindow->SetActiveObject(NULL, NULL);
m_pInPlaceFrame->SetActiveObject(NULL, NULL);
m_pInPlaceSite->OnUIDeactivate(FALSE);
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::SetObjectRects [IOleInPlaceObject]
//=--------------------------------------------------------------------------=
// Indicates how much of the control is visible.
//
// Parameters:
// LPCRECT - [in] position of the control.
// LPCRECT - [in] clipping rectangle for the control.
//
// Output:
// HRESULT - S_OK, E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED
//
// Notes:
//
STDMETHODIMP COleControl::SetObjectRects
(
LPCRECT prcPos,
LPCRECT prcClip
)
{
BOOL fRemoveWindowRgn;
// update our information
//
m_Size.cx = prcPos->right - prcPos->left;
m_Size.cy = prcPos->bottom - prcPos->top;
// move our window to the new location and handle clipping
//
if (m_hwnd) {
fRemoveWindowRgn = m_fUsingWindowRgn;
if (prcClip) {
// the container wants us to clip, so figure out if we really
// need to
//
RECT rcIXect;
IntersectRect(&rcIXect, prcPos, prcClip);
if (!EqualRect(&rcIXect, prcPos)) {
SetWindowRgn(GetOuterWindow(), CreateRectRgnIndirect(&rcIXect), TRUE);
m_fUsingWindowRgn = TRUE;
fRemoveWindowRgn = FALSE;
}
}
if (fRemoveWindowRgn) {
SetWindowRgn(GetOuterWindow(), NULL, TRUE);
m_fUsingWindowRgn = FALSE;
}
// set our control's location, but don't change it's size at all
// [people for whom zooming is important should set that up here]
//
SetWindowPos(GetOuterWindow(), NULL, prcPos->left, prcPos->top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::ReactivateAndUndo [IOleInPlaceObject]
//=--------------------------------------------------------------------------=
// Reactivates a previously deactivated object, undoing the last state of the object.
//
// Output:
// HRESULT - S_OK, E_NOTUNDOABLE
//
// Notes:
//
STDMETHODIMP COleControl::ReactivateAndUndo
(
void
)
{
// homey don't play that.
//
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::TranslateAccelerator [IOleInPlaceActiveObject]
//=--------------------------------------------------------------------------=
// Processes menu accelerator-key messages from the container's message queue.
//
// Parameters:
// LPMSG - [in] the message that has the special key in it.
//
// Output:
// HRESULT - S_OK, S_FALSE, E_UNEXPECTED
//
// Notes:
//
STDMETHODIMP COleControl::TranslateAccelerator
(
LPMSG pmsg
)
{
// see if we want it or not.
//
if (OnSpecialKey(pmsg))
return S_OK;
// if not, then we want to forward it back to the site for further processing
//
if (m_pControlSite)
return m_pControlSite->TranslateAccelerator(pmsg, _SpecialKeyState());
// we didn't want it.
//
return S_FALSE;
}
//=--------------------------------------------------------------------------=
// COleControl::OnFrameWindowActivate [IOleInPlaceActiveObject]
//=--------------------------------------------------------------------------=
// Notifies the control when the container's top-level frame window is
// activated or deactivated.
//
// Parameters:
// BOOL - [in] state of containers top level window.
//
// Output:
// HRESULT - S_OK
//
// Notes:
// - we really don't care.
//
STDMETHODIMP COleControl::OnFrameWindowActivate
(
BOOL fActivate
)
{
// not interesting
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::OnDocWindowActivate [IOleInPlaceActiveObject]
//=--------------------------------------------------------------------------=
// Notifies the active control when the container's document window is
// activated or deactivated.
//
// Parameters:
// BOOL - state of mdi child window.
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::OnDocWindowActivate
(
BOOL fActivate
)
{
// apart from that, we don't do anything.
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::ResizeBorder [IOleInPlaceActiveObject]
//=--------------------------------------------------------------------------=
// Alerts the control that it needs to resize its border space.
//
// Parameters:
// LPCRECT - [in] new outer rectangle for border space
// IOleInPlaceUIWindow * - [in] the document or frame who's border has changed
// BOOL - [in] true if it was the fram window taht called.
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::ResizeBorder
(
LPCRECT prcBorder,
IOleInPlaceUIWindow *pInPlaceUIWindow,
BOOL fFrame
)
{
// this is largely uninteresting to us, since we have no border.
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::EnableModeless [IOleInPlaceActiveObject]
//=--------------------------------------------------------------------------=
// Enables or disables modeless dialog boxes when the container creates or
// destroys a modal dialog box.
//
// Parameters:
// BOOL - [in] enable or disable modeless dialogs.
//
// Output:
// HRESULT - S_OK
//
// Notes:
//
STDMETHODIMP COleControl::EnableModeless
(
BOOL fEnable
)
{
// phenomenally uninteresting
//
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::Draw [IViewObject2]
//=--------------------------------------------------------------------------=
// Draws a representation of an object onto the specified device context.
//
// Parameters:
// DWORD - [in] draw aspect
// LONG - [in] part of object to draw [not relevant]
// void * - NULL
// DVTARGETDEVICE * - [in] specifies the target device
// HDC - [in] information context for target device
// HDC - [in] target device context
// LPCRECTL - [in] rectangle in which the object is drawn
// LPCRECTL - [in] window extent and origin for metafiles
// BOOL (*)(DWORD) - [in] callback for continuing or cancelling drawing
// DWORD - [in] parameter to pass to callback.
//
// Output:
// HRESULT
//
// Notes:
//
STDMETHODIMP COleControl::Draw
(
DWORD dwDrawAspect,
LONG lIndex,
void *IgnoreMe,
DVTARGETDEVICE *ptd,
HDC hicTargetDevice,
HDC hdcDraw,
LPCRECTL prcBounds,
LPCRECTL prcWBounds,
BOOL (__stdcall *pfnContinue)(DWORD dwContinue),
DWORD dwContinue
)
{
HRESULT hr;
RECTL rc;
POINT pVp, pW;
int iMode;
// we only support one aspect
//
if (dwDrawAspect != DVASPECT_CONTENT)
return DV_E_DVASPECT;
// first -- convert the DC back to MM_TEXT mapping mode so that the
// window proc and OnDraw can share the same painting code. save
// some information on it, so we can restore it later [without using
// a SaveDC/RestoreDC]
//
rc = *prcBounds;
LPtoDP(hdcDraw, (POINT *)&rc, 2);
GetViewportOrgEx(hdcDraw, &pVp);
GetWindowOrgEx(hdcDraw, &pW);
SetViewportOrgEx(hdcDraw, 0, 0, NULL);
SetWindowOrgEx(hdcDraw, 0, 0, NULL);
iMode = SetMapMode(hdcDraw, MM_TEXT);
// defer to the overridable OnDraw
//
hr = OnDraw(hdcDraw, &rc, &rc, hicTargetDevice);
SetViewportOrgEx(hdcDraw, pVp.x, pVp.y, NULL);
SetWindowOrgEx(hdcDraw, pW.x, pW.y, NULL);
SetMapMode(hdcDraw, iMode);
return hr;
}
//=--------------------------------------------------------------------------=
// COleControl::DoSuperClassPaint
//=--------------------------------------------------------------------------=
// design time painting of a subclassed control.
//
// Parameters:
// HDC - [in] dc to work with
// LPCRECTL - [in] rectangle to paint to. should be in pixels
//
// Output:
// HRESULT
//
// Notes:
//
HRESULT COleControl::DoSuperClassPaint
(
HDC hdc,
LPCRECTL prcBounds
)
{
HWND hwnd;
RECT rcClient;
int iMapMode;
POINT ptWOrg, ptVOrg;
SIZE sWOrg, sVOrg;
// make sure we have a window.
//
hwnd = CreateInPlaceWindow(0,0);
if (!hwnd)
return E_FAIL;
GetClientRect(hwnd, &rcClient);
// set up the DC for painting. this code largely taken from the MFC CDK
// DoSuperClassPaint() fn
//
iMapMode = SetMapMode(hdc, MM_ANISOTROPIC);
SetWindowOrgEx(hdc, 0, 0, &ptWOrg);
SetWindowExtEx(hdc, rcClient.right, rcClient.bottom, &sWOrg);
SetViewportOrgEx(hdc, prcBounds->left, prcBounds->top, &ptVOrg);
SetViewportExtEx(hdc, prcBounds->right - prcBounds->left, prcBounds->bottom - prcBounds->top, &sVOrg);
#if STRICT
CallWindowProc((WNDPROC)SUBCLASSWNDPROCOFCONTROL(m_ObjectType), hwnd, (g_fSysWin95Shell) ? WM_PRINT : WM_PAINT, (WPARAM)hdc, (LPARAM)(g_fSysWin95Shell ? PRF_CHILDREN | PRF_CLIENT : 0));
#else
CallWindowProc((FARPROC)SUBCLASSWNDPROCOFCONTROL(m_ObjectType), hwnd, (g_fSysWin95Shell) ? WM_PRINT : WM_PAINT, (WPARAM)hdc, (LPARAM)(g_fSysWin95Shell ? PRF_CHILDREN | PRF_CLIENT : 0));
#endif // STRICT
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::GetColorSet [IViewObject2]
//=--------------------------------------------------------------------------=
// Returns the logical palette that the control will use for drawing in its
// IViewObject::Draw method with the corresponding parameters.
//
// Parameters:
// DWORD - [in] how the object is to be represented
// LONG - [in] part of the object to draw [not relevant]
// void * - NULL
// DVTARGETDEVICE * - [in] specifies the target device
// HDC - [in] information context for the target device
// LOGPALETTE ** - [out] where to put palette
//
// Output:
// HRESULT - S_OK, S_FALSE
//
// Notes:
//
STDMETHODIMP COleControl::GetColorSet
(
DWORD dwDrawAspect,
LONG lindex,
void *IgnoreMe,
DVTARGETDEVICE *ptd,
HDC hicTargetDevice,
LOGPALETTE **ppColorSet
)
{
if (dwDrawAspect != DVASPECT_CONTENT)
return DV_E_DVASPECT;
*ppColorSet = NULL;
return (OnGetPalette(hicTargetDevice, ppColorSet)) ? S_OK : S_FALSE;
}
//=--------------------------------------------------------------------------=
// COleControl::Freeze [IViewObject2]
//=--------------------------------------------------------------------------=
// Freezes a certain aspect of the object's presentation so that it does not
// change until the IViewObject::Unfreeze method is called.
//
// Parameters:
// DWORD - [in] aspect
// LONG - [in] part of object to draw
// void * - NULL
// DWORD * - [out] for Unfreeze
//
// Output:
// HRESULT
//
// Notes:
//
STDMETHODIMP COleControl::Freeze
(
DWORD dwDrawAspect,
LONG lIndex,
void *IgnoreMe,
DWORD *pdwFreeze
)
{
// homey don't play that
//
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::Unfreeze [IVewObject2]
//=--------------------------------------------------------------------------=
// Releases a previously frozen drawing. The most common use of this method
// is for banded printing.
//
// Parameters:
// DWORD - [in] cookie from freeze
//
// Output:
// HRESULT
//
// Notes:
//
STDMETHODIMP COleControl::Unfreeze
(
DWORD dwFreeze
)
{
// homey don't play that.
//
return E_NOTIMPL;
}
//=--------------------------------------------------------------------------=
// COleControl::SetAdvise [IViewObject2]
//=--------------------------------------------------------------------------=
// Sets up a connection between the control and an advise sink so that the
// advise sink can be notified about changes in the control's view.
//
// Parameters:
// DWORD - [in] aspect
// DWORD - [in] info about the sink
// IAdviseSink * - [in] the sink
//
// Output:
// HRESULT
//
// Notes:
//
STDMETHODIMP COleControl::SetAdvise
(
DWORD dwAspects,
DWORD dwAdviseFlags,
IAdviseSink *pAdviseSink
)
{
// if it's not a content aspect, we don't support it.
//
if (!(dwAspects & DVASPECT_CONTENT)) {
return DV_E_DVASPECT;
}
// set up some flags [we gotta stash for GetAdvise ...]
//
m_fViewAdvisePrimeFirst = (dwAdviseFlags & ADVF_PRIMEFIRST) ? TRUE : FALSE;
m_fViewAdviseOnlyOnce = (dwAdviseFlags & ADVF_ONLYONCE) ? TRUE : FALSE;
RELEASE_OBJECT(m_pViewAdviseSink);
m_pViewAdviseSink = pAdviseSink;
ADDREF_OBJECT(m_pViewAdviseSink);
// prime them if they want it [we need to store this so they can get flags later]
//
if (m_fViewAdvisePrimeFirst)
ViewChanged();
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::GetAdvise [IViewObject2]
//=--------------------------------------------------------------------------=
// Retrieves the existing advisory connection on the control if there is one.
// This method simply returns the parameters used in the most recent call to
// the IViewObject::SetAdvise method.
//
// Parameters:
// DWORD * - [out] aspects
// DWORD * - [out] advise flags
// IAdviseSink ** - [out] the sink
//
// Output:
// HRESULT
//
// Notes;
//
STDMETHODIMP COleControl::GetAdvise
(
DWORD *pdwAspects,
DWORD *pdwAdviseFlags,
IAdviseSink **ppAdviseSink
)
{
// if they want it, give it to them
//
if (pdwAspects)
*pdwAspects = DVASPECT_CONTENT;
if (pdwAdviseFlags) {
*pdwAdviseFlags = 0;
if (m_fViewAdviseOnlyOnce) *pdwAdviseFlags |= ADVF_ONLYONCE;
if (m_fViewAdvisePrimeFirst) *pdwAdviseFlags |= ADVF_PRIMEFIRST;
}
if (ppAdviseSink) {
*ppAdviseSink = m_pViewAdviseSink;
ADDREF_OBJECT(*ppAdviseSink);
}
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::GetExtent [IViewObject2]
//=--------------------------------------------------------------------------=
// Returns the size that the control will be drawn on the
// specified target device.
//
// Parameters:
// DWORD - [in] draw aspect
// LONG - [in] part of object to draw
// DVTARGETDEVICE * - [in] information about target device
// LPSIZEL - [out] where to put the size
//
// Output:
// HRESULT
//
// Notes:
//
STDMETHODIMP COleControl::GetExtent
(
DWORD dwDrawAspect,
LONG lindex,
DVTARGETDEVICE *ptd,
LPSIZEL psizel
)
{
// we already have an implementation of this [from IOleObject]
//
return GetExtent(dwDrawAspect, psizel);
}
//=--------------------------------------------------------------------------=
// COleControl::GetClassInfo [IProvideClassInfo]
//=--------------------------------------------------------------------------=
// returns the TypeInfo for the control's coclass.
//
// Parameters:
// ITypeInfo ** - [out]
//
// Output:
// HRESULT
//
// Notes:
//
STDMETHODIMP COleControl::GetClassInfo
(
ITypeInfo **ppTypeInfo
)
{
ITypeLib *pTypeLib;
HRESULT hr;
CHECK_POINTER(ppTypeInfo);
*ppTypeInfo = NULL;
// go and get our type library.
// CONSIDER: - go to the same sorta scheme that we use for TypeInfo caching.
// CONSIDER: - consider trying to register our typelib if this fails.
//
hr = LoadRegTypeLib(*g_pLibid, (USHORT)VERSIONOFOBJECT(m_ObjectType), 0,
LANGIDFROMLCID(g_lcidLocale), &pTypeLib);
RETURN_ON_FAILURE(hr);
// got the typelib. get typeinfo for our coclass.
//
hr = pTypeLib->GetTypeInfoOfGuid((REFIID)CLSIDOFOBJECT(m_ObjectType), ppTypeInfo);
pTypeLib->Release();
RETURN_ON_FAILURE(hr);
return S_OK;
}
//=--------------------------------------------------------------------------=
// COleControl::ViewChange [callable]
//=--------------------------------------------------------------------------=
// called whenever the view of the object has changed.
//
// Notes:
//
void COleControl::ViewChanged
(
void
)
{
// send the view change notification to anybody listening.
//
if (m_pViewAdviseSink) {
m_pViewAdviseSink->OnViewChange(DVASPECT_CONTENT, -1);
// if they only asked to be advised once, kill the connection
//
if (m_fViewAdviseOnlyOnce)
SetAdvise(DVASPECT_CONTENT, 0, NULL);
}
}
//=--------------------------------------------------------------------------=
// COleControl::SetInPlaceVisible [helper]
//=--------------------------------------------------------------------------=
// controls the visibility of the control window.
//
// Parameters:
// BOOL - TRUE shows FALSE hides.
//
// Notes:
//
void COleControl::SetInPlaceVisible
(
BOOL fShow
)
{
BOOL fVisible;
m_fInPlaceVisible = fShow;
// don't do anything if we don't have a window. otherwise, set it
//
if (m_hwnd) {
fVisible = ((GetWindowLong(GetOuterWindow(), GWL_STYLE) & WS_VISIBLE) != 0);
if (fVisible && !fShow)
ShowWindow(GetOuterWindow(), SW_HIDE);
else if (!fVisible && fShow)
ShowWindow(GetOuterWindow(), SW_SHOWNA);
}
}
//=--------------------------------------------------------------------------=
// COleControl::AmbientPropertyChanged [overridable]
//=--------------------------------------------------------------------------=
// a method that derived controls can override to do whatever they want.
// we don't particularily care about this event.
//
// Parameters:
// DISPID - [in] dispid of prop that changed.
//
// Notes:
//
void COleControl::AmbientPropertyChanged
(
DISPID dispid
)
{
// do nothing
}
//=--------------------------------------------------------------------------=
// COleControl::DoCustomVerb [overridable]
//=--------------------------------------------------------------------------=
// we were asked to execute a verb we don't know about right away. see if
// it's a verb that the dervied-control defined.
//
// Parameters:
// LONG - [in] the verb.
//
// Output:
// HRESULT - S_OK, OLEOBJ_S_INVALIDVERB
//
// Notes:
//
HRESULT COleControl::DoCustomVerb
(
LONG lVerb
)
{
return OLEOBJ_S_INVALIDVERB;
}
//=--------------------------------------------------------------------------=
// COleControl::OnSetExtent [overridable]
//=--------------------------------------------------------------------------=
// let the user do something in the resize, if they care.
//
// Parameters:
// SIZEL * - [in] new values.
//
// Output:
// BOOL - FALSE means keep current size
//
// Notes:
//
BOOL COleControl::OnSetExtent
(
SIZEL *pSizeL
)
{
return TRUE;
}
//=--------------------------------------------------------------------------=
// COleControl::OnSpecialKey [overridable]
//=--------------------------------------------------------------------------=
// allows controls to handle special keys such as arrows, CTRL+, etc ...
//
// Parameters:
// LPMSG - [in] the special key msg.
//
// Output:
// BOOL - TRUE we processed it, FALSE we didn't.
//
// Notes:
//
BOOL COleControl::OnSpecialKey
(
LPMSG pmsg
)
{
// do nothing.
//
return FALSE;
}
//=--------------------------------------------------------------------------=
// COleControl::ModalDialog [callable, utility]
//=--------------------------------------------------------------------------=
// should be called when the control is about to show and hide a modal dialog.
//
// Parameters:
// BOOL - [in] true means showing a modal dialog, false means done
//
// Notes:
//
void COleControl::ModalDialog
(
BOOL fShow
)
{
// notify the container of our intention to show a modal dialog...
//
if (m_pInPlaceFrame)
m_pInPlaceFrame->EnableModeless(!fShow);
}
//=--------------------------------------------------------------------------=
// COleControl::BeforeDestroyWindow [overridable]
//=--------------------------------------------------------------------------=
// called just before we destroy a window. gives the user the opportunity to
// save information out, especially if they're a subclassed control, and this
// is an interesting thing to do.
//
// Notes:
//
void COleControl::BeforeDestroyWindow
(
void
)
{
// fweeee
}
//=--------------------------------------------------------------------------=
// COleControl::BeforeCreateWindow [overridable]
//=--------------------------------------------------------------------------=
// called just before we create a window. the user should register their
// window class here, and set up any other things, such as the title of
// the window, and/or sytle bits, etc ...
//
// Notes:
//
void COleControl::BeforeCreateWindow
(
void
)
{
// blaugh
}
//=--------------------------------------------------------------------------=
// COleControl::OnGetPalette [overridable]
//=--------------------------------------------------------------------------=
// called when the host wants palette information. ideally, people should use
// this sparingly and carefully.
//
// Parameters:
// HDC - [in] HIC for the target device
// LOGPALETTE ** - [out] where to put the palette
//
// Output:
// BOOL - TRUE means we processed it, false means nope.
//
// Notes:
//
BOOL COleControl::OnGetPalette
(
HDC hicTargetDevice,
LOGPALETTE **ppColorSet
)
{
return FALSE;
}